package com.br4mmie.asciistory.battle;
/**
 * Encounter Creature, describes an actor in battle. super to both enemy and EncounterPlayer
 * @author Niels
 *
 */
public class EncounterCreature {

	protected int maxHP; //Maximum HP for the creature
	protected int currentHP; //Current HP for the creature
	protected String name; //the Creature's name
	protected int defense; //the Creature's defense
	protected int bonusDamage; //the Creature's bonusDamage
	protected Battle myBattle; //the Battle the creature exists in

	/**
	 * Empty constructor, needs to be overwritten in subclasses
	 */
	EncounterCreature()
	{	
	}
	
	/**
	 * TakeDamage function, calculates the actual damage or healing the creature takes
	 * @param damage
	 * @param b
	 */
	public void takeDamage(int damage, Battle b)
	{
		if (damage < 0)
		{
			b.addMessage(name + " is healed for " + damage);
			currentHP -= damage;
		}
		else
		{
			int restDamage;
			
			if (defense > damage) restDamage = 0;
			else restDamage = (damage-defense);
			currentHP -= restDamage;
			b.addMessage(name + " is hit for " + restDamage);
		}
		if (currentHP > maxHP) currentHP = maxHP;
	}
	
	/**
	 * Empty on draw function, needs to be overwritten in subclasses
	 */
	public void onDraw()
	{
		
	}
	
	/**
	 * Empty act function, needs to be overwritten in subclasses
	 */
	public void act()
	{
		
	}
	
	
	public String getName() 
	{
		return name;
	}
	public void setName(String name) 
	{
		this.name = name;
	}
	public int getMaxHP() 
	{
		return maxHP;
	}
	public void setMaxHP(int maxHP) 
	{
		this.maxHP = maxHP;
	}
	public int getCurrentHP() 
	{
		return currentHP;
	}
	public void setCurrentHP(int currentHP) 
	{
		this.currentHP = currentHP;
	}
	
	public int getDefense() 
	{
		return defense;
	}
	public void setDefense(int defense) 
	{
		this.defense = defense;
	}
	public int getBonusDamage() 
	{
		return bonusDamage;
	}
	public void setBonusDamage(int bonusDamage) 
	{
		this.bonusDamage = bonusDamage;
	}
	public Battle getBattle() 
	{
		return myBattle;
	}
	public void setBattle(Battle myBattle) 
	{
		this.myBattle = myBattle;
	}

}
